#!/bin/sh

# Author - Zhao Dong

ncc_srv_pid=`ps -ef | grep AccessSessionManagementService-0.0.1-SNAPSHOT.jar | grep -v grep | awk '{print $2}'`

if [ $ncc_srv_pid ]; then
	echo "ncc service is running, and ncc_srv_pid is $ncc_srv_pid"
else
	echo "ncc_srv_pid is not available, and start the ncc service"
	service ncc-server start
	sleep 10
	ncc_srv_pid=`ps -ef | grep AccessSessionManagementService-0.0.1-SNAPSHOT.jar | grep -v grep | awk '{print $2}'`

	if [ $ncc_srv_pid ]; then
		echo start ncc service successfully
	else 
		echo "can't start the ncc service"
		systemctl keepalived stop
	fi

fi

